package com.thinkgem.jeesite.modules.spider.downloader;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;

import com.virjar.dungproxy.client.webmagic.DungProxyDownloader;

import us.codecraft.webmagic.Page;

public class OfflineProxyDownloader extends DungProxyDownloader {
    @Override
    protected boolean needOfflineProxy(Page page) {
    	String code = page.getStatusCode() + "";
        if(code.trim().startsWith("4")){//父类默认下线 401和403,你也可以不调用
            return true;
        }else{
            return StringUtils.containsIgnoreCase(page.getRawText(), "请求");
        }
    }
    @Override
    protected boolean needOfflineProxy(IOException e) {
        //return e instanceof SSLException;//如果异常类型是SSL,代表IP被封禁,你也可以不实现
        return false;
    }
}
